//202102104015柴亚楠
package util;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;

import java.util.List;


public class ControllerHelper {
    /**
     * 获得代表查询条件的List对象
     * @param req_jsonObj 请求body对应的JSONObject对象
     * @return 代表查询条件的List对象
     */
    public static List<Condition> getConditions(JSONObject req_jsonObj) {


        JSONArray conditionList_jsonArray =
                req_jsonObj.getJSONArray("conditionList");
        JSONArray conditionList_jsonArray2 =
                req_jsonObj.getJSONArray("teacherId");
        List<Condition> conditionList = null;
        if (conditionList_jsonArray != null) {
            conditionList = conditionList_jsonArray.toJavaList(Condition.class);
        }
        if (conditionList_jsonArray2 != null) {
            conditionList = conditionList_jsonArray2.toJavaList(Condition.class);
        }
        return conditionList;
    }
    /**
     * 获得代表查询条件的Pagination对象
     * @param req_jsonObj 请求body对应的JSONObject对象
     * @return 代表查询条件的Pagination对象
     */
    public static Pagination getPagination(JSONObject req_jsonObj) {
        JSONObject pagination_jsonObj =
                req_jsonObj.getJSONObject("pagination");
        Pagination pagination = null;
        if (pagination_jsonObj != null) {
            pagination = pagination_jsonObj
                    .toJavaObject(Pagination.class);
        }
        return pagination;
    }
}
